package com.hustzp.com.xichuangzhu;

import android.app.Application;
import android.test.ApplicationTestCase;
import android.util.Log;

import com.avos.avoscloud.AVException;
import com.avos.avoscloud.AVObject;
import com.avos.avoscloud.AVQuery;
import com.hustzp.com.xichuangzhu.dao.CollectionKindsDao;
import com.hustzp.com.xichuangzhu.model.CollectionKinds;
import com.hustzp.com.xichuangzhu.poetry.model.LikePost;

import java.util.List;

/**
 * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
 */
public class ApplicationTest extends ApplicationTestCase<Application> {
    public ApplicationTest() {
        super(Application.class);
    }

    public void test1() {
        CollectionKindsDao dao = new CollectionKindsDao(getContext());

        List<CollectionKinds> collectionKindses = dao.getCollectioinKinds();
//        Log.e("wzm", collectionKindses.toString());

        for (CollectionKinds kind :
                collectionKindses) {
            Log.e("wzm", dao.getCollectioins(kind).toString());
        }
    }

    public void test2() {
        AVObject channel = AVObject.createWithoutData("objectId", "56ebd926f3609a00545a5a73");
        AVQuery<LikePost> query = AVQuery.getQuery(LikePost.class);
        query.whereEqualTo("channel", channel);
        query.setCachePolicy(AVQuery.CachePolicy.CACHE_ELSE_NETWORK);
        query.limit(10);
        query.skip(0);
        query.orderByAscending("createdAt");
        query.include("user");
        try {
            List<LikePost> list = query.find();
            Log.e("wzm", list.toString());
        } catch (AVException e) {
            e.printStackTrace();
        }
//        query.findInBackground(new FindCallback<LikePost>() {
//            @Override
//            public void done(List<LikePost> list, AVException e) {
//                if (list != null)
//                    Log.e("wzm", list.toString());
//            }
//        });
    }
}